#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：图灵学习 
@File    ：13.课间联系.py
@IDE     ：PyCharm 
@Author  ：ChenLiGao
@Date    ：2024-10-22 14:48
'''
"""
    解释为什么最后一个元素没有被删除，
        因为删除列表元素过程中，列表的下标序号发生变化了，取值时，最后一个值取不到
"""
data_list = ["a1", "b2", "b3", "a1", "a1"]
for temp in data_list:
    if temp == "a1":
        data_list.remove(temp)

print(data_list)

data_list = ["a1", "b2", "b3", "a1", "a1"]
new_list = []
for temp in data_list:
    if temp != "a1":
        new_list.append(temp)

print(new_list)

data_list = ["a1", "b2", "b3", "a1", "a1"]
reversed_list = list(reversed(data_list))
for temp in reversed_list:
    if temp == "a1":
        data_list.remove(temp)

print(reversed_list)
print(data_list)